package com.css.fxfzxczh.modules.synthesizeInfoManage.earEveManage.service.impl;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.css.fxfzxczh.base.response.ResponseCode;
import com.css.fxfzxczh.constants.FxfzConstants;
import com.css.fxfzxczh.constants.YNEnum;
import com.css.fxfzxczh.modules.aftershockSequence.entity.RealEarthquakeEntity;
import com.css.fxfzxczh.modules.aftershockSequence.service.SetEarthquakeMapService;
import com.css.fxfzxczh.modules.buildingKilometerGrid.exceptions.BizException;
import com.css.fxfzxczh.modules.disasterSituationDataManage.emergencyReport.repository.EmergencyReportRepository;
import com.css.fxfzxczh.modules.disasterSituationDataManage.houMonData.repository.HouMonDataRepository;
import com.css.fxfzxczh.modules.disasterSituationDataManage.lifeline.repository.LifelineRepository;
import com.css.fxfzxczh.modules.disasterSituationDataManage.samPoiData.repository.SamPoiDataRepository;
import com.css.fxfzxczh.modules.disasterSituationDataManage.samPoiHouSur.repository.SamPoliHouSurRepository;
import com.css.fxfzxczh.modules.fieldWorkManage.InvestigationGroupManage.repository.InvestigationGroupRepository;
import com.css.fxfzxczh.modules.fieldWorkManage.lnvestigationTaskMange.service.InvTaskManageService;
import com.css.fxfzxczh.modules.fieldWorkManage.lnvestigationTaskMange.vo.InvestigationTaskVo;
import com.css.fxfzxczh.modules.fieldWorkManage.surTaskManage.entity.SurTaskManage;
import com.css.fxfzxczh.modules.fieldWorkManage.surTaskManage.repository.SurTaskManageRepository;
import com.css.fxfzxczh.modules.report.entity.Report;
import com.css.fxfzxczh.modules.report.service.ReportService;
import com.css.fxfzxczh.modules.synthesizeInfoManage.earEveManage.entity.EarEveManage;
import com.css.fxfzxczh.modules.synthesizeInfoManage.earEveManage.entity.EarEveUser;
import com.css.fxfzxczh.modules.synthesizeInfoManage.earEveManage.entity.JcStrongCatalog;
import com.css.fxfzxczh.modules.synthesizeInfoManage.earEveManage.entity.SimEarthquake;
import com.css.fxfzxczh.modules.synthesizeInfoManage.earEveManage.entity.resp.JCSJDzsjResp;
import com.css.fxfzxczh.modules.synthesizeInfoManage.earEveManage.queryParams.EarEveManageQuaParams;
import com.css.fxfzxczh.modules.synthesizeInfoManage.earEveManage.repository.EarEveManageRepository;
import com.css.fxfzxczh.modules.synthesizeInfoManage.earEveManage.repository.EarEveUserRepository;
import com.css.fxfzxczh.modules.synthesizeInfoManage.earEveManage.repository.SimEarthquakeRepository;
import com.css.fxfzxczh.modules.synthesizeInfoManage.earEveManage.repository.impl.EarEveManageRepositoryImpl;
import com.css.fxfzxczh.modules.synthesizeInfoManage.earEveManage.repository.impl.EarEveUserRepositoryImpl;
import com.css.fxfzxczh.modules.synthesizeInfoManage.earEveManage.repository.impl.SimEarthquakeRepositoryImpl;
import com.css.fxfzxczh.modules.synthesizeInfoManage.earEveManage.service.EarEveManageService;
import com.css.fxfzxczh.modules.synthesizeInfoManage.earEveManage.vo.EarEveManageVo;
import com.css.fxfzxczh.modules.synthesizeInfoManage.heaManage.entity.HeaManage;
import com.css.fxfzxczh.modules.synthesizeInfoManage.heaManage.repository.HeaManageRepository;
import com.css.fxfzxczh.modules.synthesizeInfoManage.heaManage.service.HeaManageService;
import com.css.fxfzxczh.modules.synthesizeInfoManage.knowledgeManagement.entity.KnowledgeManagement;
import com.css.fxfzxczh.modules.synthesizeInfoManage.knowledgeManagement.repository.KnowledgeManagementRepository;
import com.css.fxfzxczh.modules.synthesizeInfoManage.matManage.entity.MatManage;
import com.css.fxfzxczh.modules.synthesizeInfoManage.matManage.repository.MatManageRepository;
import com.css.fxfzxczh.modules.synthesizeInfoManage.matManage.service.MatManageService;
import com.css.fxfzxczh.modules.synthesizeInfoManage.personnelManagement.entity.PersonnelManagement;
import com.css.fxfzxczh.modules.synthesizeInfoManage.personnelManagement.repository.PersonnelManagementRepository;
import com.css.fxfzxczh.modules.synthesizeInfoManage.personnelManagement.service.PersonnelManagementService;
import com.css.fxfzxczh.util.CreateGson;
import com.css.fxfzxczh.util.PlatformObjectUtils;
import com.css.fxfzxczh.util.UUIDGenerator;
import com.css.fxfzxczh.util.Xml2ObjectUtil;
import com.css.fxfzxczh.web.PlatformSessionContext;
import com.css.fxfzxczh.zcpt.sys.entity.SUser;
import com.css.fxfzxczh.zcpt.sys.service.SUserService;
import com.css.fxfzxczh.zcpt.sys.service.SysRoleService;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.slw.common.helper.PropsHelper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;
import java.io.IOException;
import java.math.BigDecimal;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;

@Slf4j
@Service
public class EarEveManageServiceImpl implements EarEveManageService {
    @Resource
    EarEveManageRepository earEveManageRepository;

    @Resource
    EarEveUserRepository earEveUserRepository;

    @Resource
    SimEarthquakeRepository simEarthquakeRepository;

    @Resource
    SysRoleService sysRoleService;

    @Resource
    SUserService sUserService;

    @Autowired
    private RestTemplate restTemplate;

    //现场人员
    @Resource
    PersonnelManagementRepository personnelManagementRepository;

    //车辆
    @Resource
    HeaManageRepository heaManageRepository;

    //物资
    @Resource
    MatManageRepository matManageRepository;

    //知识库
    @Resource
    KnowledgeManagementRepository knowledgeManagementRepository;

    //评估子区
    @Resource
    SurTaskManageRepository surTaskManageRepository;

    //抽样点
    @Resource
    SamPoiDataRepository samPoiDataRepository;

    //抽样点房屋
    @Resource
    SamPoliHouSurRepository samPoliHouSurRepository;

    //房屋单体
    @Resource
    HouMonDataRepository houMonDataRepository;

    //调查组
    @Resource
    private InvestigationGroupRepository investigationGroupRepository;

    //灾情急报
    @Resource
    EmergencyReportRepository emergencyReportRepository;

    @Resource
    LifelineRepository lifelineRepository;

    @Resource
    private InvTaskManageService invTaskManageService;

    @Resource
    private ReportService reportService;

    @Resource
    private SetEarthquakeMapService setEarthquakeMapService;


    @Override
    public Map<String, Object> getPage(EarEveManageQuaParams queParams, int curPage, int pageSize) {
        Map<String, Object> page = earEveManageRepository.getPage(queParams, curPage, pageSize);
        return page;
    }

    @Override
    public void delete(String id) {
        EarEveManage earEveManage = earEveManageRepository.findById(id);
        String userId = PlatformSessionContext.getUserID();
        String role = sysRoleService.getRoleByUserId(userId);
        StringBuilder str = new StringBuilder("");
        List<Map> roleMaps = JSONObject.parseArray(role, Map.class);
        for (Map roleMap : roleMaps) {
            str.append(roleMap.get("roleCode") + ",");
        }
        String roles = str.toString();
        if (roles.contains(FxfzConstants.XCZH_COUNTRY_ROLE)) {
            earEveManageRepository.delete(id);
        }
        if (roles.contains(FxfzConstants.XCZH_PROVINCE_ROLE)) {
            if (!userId.equals(earEveManage.getCreateUser())) {
                throw new RuntimeException("删除失败，只能删除自己本省下的数据");
            }
            if ("1".equals(earEveManage.getIsRelation())) {
                throw new RuntimeException("删除失败，已经被关联的地震事件不能进行删除");
            }
            earEveManageRepository.delete(id);
        }
    }

    @Override
    public void completion(String id) {
        earEveManageRepository.completion(id);
    }

    @Override
    public void update(EarEveManage earEveManage) {
        String userId = PlatformSessionContext.getUserID();
        String role = sysRoleService.getRoleByUserId(userId);
        StringBuilder str = new StringBuilder("");
        List<Map> roleMaps = JSONObject.parseArray(role, Map.class);
        for (Map roleMap : roleMaps) {
            str.append(roleMap.get("roleCode") + ",");
        }
        String roles = str.toString();
        earEveManage.setUpdateTime(new Date());
        earEveManage.setUpdateUser(userId);
        /*if (roles.contains(FxfzConstants.XCZH_COUNTRY_ROLE)) {
            earEveManageRepository.update(earEveManage);
        }
        if (roles.contains(FxfzConstants.XCZH_PROVINCE_ROLE)) {
            if (!userId.equals(earEveManage.getCreateUser())) {
                throw new RuntimeException("修改失败，只能修改自己本省下的数据");
            }
            earEveManageRepository.update(earEveManage);
        }*/
        earEveManageRepository.update(earEveManage);
    }

    @Override
    public void save(EarEveManage earEveManage) {
        // TODO: 2023/8/28  暂时去掉判断方便培训
        EarEveManage earEveManage1=earEveManageRepository.findBySeismicCode(earEveManage.getSeismicCode());
        if(!PlatformObjectUtils.isEmpty(earEveManage1)){
            throw new RuntimeException("保存失败，一个地震只能生成一个地震事件");
        }
        earEveManage.setXsemId(UUIDGenerator.getUUID());
        earEveManage.setDelFlag(YNEnum.N.toString());
        earEveManage.setIsRelation(YNEnum.N.toString());
        earEveManage.setEventStatus(YNEnum.N.toString());
        earEveManage.setJscId(earEveManage.getJscId());
        earEveManageRepository.save(earEveManage);
        //修改地震是否创建过地震的标识

    }

    @Override
    public void updateRelationStatus(String xsemId) {
        earEveManageRepository.updateRelationStatus(xsemId);
    }

    @Override
    @Transactional
    public void setCurEvent(String id) {
        /*String userId = PlatformSessionContext.getUserID();
        EarEveManage earEveManage = earEveManageRepository.selWheHavCurEvent(id,userId);
        if (!PlatformObjectUtils.isEmpty(earEveManage)) {
            earEveManageRepository.updateCurEvent(id);
        }
        earEveManageRepository.setCurEvent(id);*/
        String userId = PlatformSessionContext.getUserID();
        EarEveUser curEvent = earEveUserRepository.selWheHavCurEvent(userId);
        if(PlatformObjectUtils.isNotEmpty(curEvent)){
            earEveUserRepository.updateCurEvent(id,curEvent.getUserId());
        }else{
            EarEveUser earEveUser=new EarEveUser();
            earEveUser.setId(UUIDGenerator.getUUID());
            earEveUser.setUserId(userId);
            earEveUser.setXsemId(id);
            earEveUser.setIsCurrentEvent("1");
            earEveUserRepository.save(earEveUser);
        }
    }

    @Override
    public Map<String,Object> getEarInfo(int curPage,int pageSize,String magnitude,String dataSource) {
        Map<String, Object> map = new HashMap<>();

        List<JcStrongCatalog> list =new ArrayList<>();
        //真实地震
        List<JcStrongCatalog> reallist = getJCSJPage(magnitude);
        //模拟地震
        List<JcStrongCatalog> simEarList=simEarthquakeRepository.getSimEarList(magnitude);
        if(PlatformObjectUtils.isNotEmpty(dataSource)){
            if("0".equals(dataSource)){
                list=reallist;
            }else{
                list=simEarList;
            }
        }else{
            list.addAll(simEarList);
            list.addAll(reallist);
        }
        List<JcStrongCatalog> pageList = startPage(list, curPage, pageSize);
        // 使用Comparator比较器来排序
        Comparator<JcStrongCatalog> comparator = Comparator.comparing(JcStrongCatalog::getCreateTime);
        // 使用reversed()方法使排序降序
        comparator = comparator.reversed();
        // 调用sort方法对列表进行排序
        Collections.sort(pageList, comparator);
        if(pageList.size()>0){
            for(JcStrongCatalog item:list){
                StringBuilder str=new StringBuilder("");
                String eventId = item.getEventId();
                EarEveManage earEveManage1 = null;
                if("0".equals(dataSource)){
                    eventId = item.getJscId();
                    earEveManage1 = earEveManageRepository.findByJscId(eventId);
                }
                if(earEveManage1 == null){
                    earEveManage1=earEveManageRepository.findBySeismicCode(item.getEventId());
                }
                if(!PlatformObjectUtils.isEmpty(earEveManage1)){
                    item.setCreateOrNot("0");
                }else{
                    item.setCreateOrNot("1");
                }

                if(!PlatformObjectUtils.isEmpty(item.getFzTime())){
                    item.setDataSource("0");
                }else{
                    String transTime = getTransTime(str.append(item.getOccurrenceDate()).append(" ").append(item.getOccurrenceTime()).toString());
                    item.setFzTime(transTime);
                    item.setDataSource("1");
                }
            }

        }
        map.put("total", list.size());
        map.put("rows", pageList);
        return map;
    }

    private  List<JcStrongCatalog> startPage(List<JcStrongCatalog> list, Integer pageNum, Integer pageSize) {
        if (list.isEmpty()) {
            return new ArrayList<>();
        }

        int count = list.size();
        //int pageCount = (int) Math.ceil((double) count / pageSize);  // 使用 Math.ceil 计算 pageCount

        int fromIndex = (pageNum - 1) * pageSize;
        int toIndex = Math.min(fromIndex + pageSize, count);  // 确保 toIndex 不超过列表范围

        return list.subList(fromIndex, toIndex);
    }

    @Override
    public Map<String,Object> getEventName(EarEveManageQuaParams params) {
        Map<String,Object> map=new HashMap<>();
        StringBuilder eventNameStr=new StringBuilder("");
        String[] split1 ;
        if(StringUtils.isNotBlank(params.getOccurrenceDate())){
            split1 = params.getOccurrenceDate().split("-");
        }else{
            split1 = new String[3];
            split1[0] = params.getFzTime().toString().substring(0,4);
            split1[1] = params.getFzTime().substring(4,6);
            split1[2] = params.getFzTime().substring(6,8);
        }

        String magnitudeStr = params.getMagnitude().substring(0, params.getMagnitude().lastIndexOf(".")+2);
        eventNameStr.append(split1[0]+"年"+split1[1]+"月"+split1[2]+"日"+params.getLocation()+magnitudeStr+"级地震");

        StringBuilder eventCode=new StringBuilder("");
        String magnitude = params.getMagnitude().substring(0, params.getMagnitude().lastIndexOf(".")+2).replace(".","");

        String userId = PlatformSessionContext.getUserID();
        String user = sUserService.getSUser(userId);
        SUser sUser = CreateGson.createGson().fromJson(user, SUser.class);
        map.put("createUserName", sUser.getUserName());
        map.put("createUser", sUser.getUserId());
        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");


        map.put("createTime", dateFormat.format(new Date()));
        //map.put("createUnit", sUser.getDeptEntity().getDeptName());
        map.put("createUnit", sUser.getOrgName());
        map.put("eventName",eventNameStr.toString());
        map.put("eventCode",eventCode.append(params.getFzTime().substring(0,12)).append(magnitude).toString());
        return map;
    }

    @Override
    public EarEveManage findById(String id) {

        return earEveManageRepository.findById(id);
    }

    @Override
    public EarEveManage getCurrentEvent() {
        String userId = PlatformSessionContext.getUserID();
        return earEveManageRepository.getCurrentEvent(userId);
    }

    @Override
    public List<EarEveManage> getList() {
        List<EarEveManage> list = earEveManageRepository.getList();
        return list;
    }

    @Override
    public List<EarEveManage> getAllEarEveManage() {
        return earEveManageRepository.getAllEarEveManage();
    }

    @Transactional
    @Override
    public void convert(EarEveManageVo earEveManageVo) {
        EarEveManage earEveManage1=earEveManageRepository.findBySeismicCode(earEveManageVo.getSeismicCode());
        if(!PlatformObjectUtils.isEmpty(earEveManage1)){
            throw new RuntimeException("创建失败，一个地震只能生成一个地震事件");
        }
        //保存转换后的地震事件
        EarEveManage earEveManage=new EarEveManage();
        BeanUtils.copyProperties(earEveManageVo, earEveManage);
        String xsemId = UUIDGenerator.getUUID();
        String convertedXsemId = earEveManageVo.getConvertedXsemId();
        earEveManage.setXsemId(xsemId);
        earEveManage.setDelFlag(YNEnum.N.toString());
        earEveManage.setIsRelation(YNEnum.N.toString());
        //earEveManage.setIsCurrentEvent(YNEnum.N.toString());
        //地震事件状态 0进行中，1结束，2已转换
        earEveManage.setEventStatus("0");
        earEveManageRepository.save(earEveManage);

        //将被转换的地震事件状态置为已转换
        earEveManageRepository.updateEventStatus(convertedXsemId,"2");

        //现场人员数据转换
        //personnelManagementRepository.updateXsemId(xsemId,convertedXsemId);
        //指挥部数据转换
        //heaManageRepository.updateXsemId(xsemId,convertedXsemId);
        //物资数据转换
        //matManageRepository.updateXsemId(xsemId,convertedXsemId);
        //知识库数据转换
        //knowledgeManagementRepository.updateXsemId(xsemId,convertedXsemId);
        //评估子区数据转换
        //surTaskManageRepository.updateXsemId(xsemId,convertedXsemId);
        //抽样点数据转换
        //samPoiDataRepository.updateXsemId(xsemId,convertedXsemId);
        //抽样点房屋数据转换
        //samPoliHouSurRepository.updateXsemId(xsemId,convertedXsemId);
        //房屋单体数据转换
        //houMonDataRepository.updateXsemId(xsemId,convertedXsemId);
        //调查组数据转换
        //investigationGroupRepository.updateXsemId(xsemId,convertedXsemId);
        //灾情急报数据转换
        //emergencyReportRepository.updateXsemId(xsemId,convertedXsemId);
        //生命线数据转换
        lifelineRepository.updateXsemId(xsemId,convertedXsemId);

    }

    @Override
    public List<EarEveManageVo> getAppPage() {

        return earEveManageRepository.getAppPage();
    }

    @Override
    public void simEarSave(SimEarthquake simEarthquake) {
        simEarthquake.setJscId(UUIDGenerator.getUUID());
        simEarthquake.setCreateUser(PlatformSessionContext.getUserID());
        simEarthquake.setCreateTime(new Date());
        simEarthquake.setDelFlag(YNEnum.N.toString());
        simEarthquake.setEventId(UUIDGenerator.getUUID().substring(0, 10));
        simEarthquakeRepository.simEarSave(simEarthquake);
    }

    @Override
    public void simEarDelete(String id) {
        simEarthquakeRepository.simEarDelete(id);
    }

    @Override
    public void simEarUpdate(SimEarthquake simEarthquake) {
        simEarthquake.setUpdateUser(PlatformSessionContext.getUserID());
        simEarthquake.setUpdateTime(new Date());
        simEarthquakeRepository.simEarUpdate(simEarthquake);
    }

    @Override
    public String endSeismicEventCheck(String id) {
        List<InvestigationTaskVo> taskList = invTaskManageService.getTaskList(id, "");
        StringBuilder str = new StringBuilder("");
        if (taskList.isEmpty()) {
            str.append("该地震事件下没有调查任务;");
        } else {
            for (InvestigationTaskVo investigationTask : taskList) {
                if (!"2".equals(investigationTask.getTaskStatus())) {
                    str.append(investigationTask.getTaskName() + "，");
                }
            }
            if (str.length() > 0) {
                //throw new RuntimeException("该地震事件下有未完成的调查任务，请先完成调查任务再结束地震事件");
                str.append("该地震事件下这些调查任务尚未结束;");
            }
        }

        List<Report> reports = reportService.getReports(id);
        if (reports.isEmpty()) {
            str.append("该地震事件下还未上传报告;");
        }

        str.append("结束地震事件后所有数据都不可以修改和生成，只可查看，请确认是否继续结束？");
        return str.toString();
    }

    @Override
    public void endSeismicEvent(String id) {
        earEveManageRepository.endSeismicEvent(id, "1", new Date());
    }

    @Override
    public void updateFileIdById(String xsemId, String attachId) {
        earEveManageRepository.updateFileIdById(xsemId,attachId);
    }

    private String getTransTime(String timeStr) {
        int dotIndex = timeStr.indexOf('.');
        if (dotIndex != -1) {
            timeStr = timeStr.substring(0, dotIndex);
        }

        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-M-dd HH:mm:ss");
        LocalDateTime date = LocalDateTime.parse(timeStr, df);
        DateTimeFormatter f2 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        String transTime = f2.format(date);

        return transTime;
    }

    public List<JcStrongCatalog> getJCSJPage(String magnitude)  {
        Properties configGroup = PropsHelper.loadProps("slw-config.properties");
        String url = configGroup.getProperty("taiWangRestUrl");
        List<JcStrongCatalog> list = new LinkedList<>();
        list = this.getTaiwanNetworkEarthquake(url,magnitude);
        return list;



//        StringBuilder queryStr=new StringBuilder();
//        if(PlatformObjectUtils.isNotEmpty(magnitude)){
//            queryStr.append("?magnitude="+magnitude+"");
//        }
//
//        Properties configGroup = PropsHelper.loadProps("slw-config.properties");
//        String url = configGroup.getProperty("sjxtRestUrl") + "/datacenter/jcStrongCatalog/getDataList";
//        JSONObject valueMap = new JSONObject();
//        HttpHeaders headers = new HttpHeaders();
//        headers.setContentType(MediaType.APPLICATION_JSON);
//        headers.set("Authorization", "fxfzxczh");
//        headers.set("subsystemCode", "dzxczhsspgzxt");
//        HttpEntity<JSONObject> r = new HttpEntity<>(valueMap, headers);
//        String url1 = new StringBuilder(url).append(queryStr).toString();
//        JSONArray data = restTemplate.exchange(url1, HttpMethod.GET, r, JSONObject.class).getBody().getJSONArray("data");
//        ObjectMapper objectMapper = new ObjectMapper();
//
//        try {
//            // 使用TypeReference指定泛型类型
//            //List<JcStrongCatalog> jcStrongCatalogs = objectMapper.readValue(data.toString(), new TypeReference<List<JcStrongCatalog>>() {});
//            return objectMapper.readValue(data.toString(), new TypeReference<List<JcStrongCatalog>>() {});
//        } catch (IOException e) {
//            return new ArrayList<>();
//        }
    }

    private List<JcStrongCatalog> getTaiwanNetworkEarthquake(String url,String magnitude) {
        List<JcStrongCatalog> list = Xml2ObjectUtil.getTaiwanNetworkEarthquake(url,magnitude);
        if (CollectionUtils.isEmpty(list)){
            return Collections.emptyList();
        }
        for (int i = list.size()-1; i >= 0; i--) {
            JcStrongCatalog item = list.get(i);
            String longitude = item.getLongitude().toString();
            String latitude = item.getLatitude().toString();
            List<String> provinceInfo = setEarthquakeMapService.queryProvinceByLonLat(longitude, latitude.toString());
            if (PlatformObjectUtils.isEmpty(provinceInfo)) {
                list.remove(i);
                //中国海域
                continue;
            }
            item.setProvince(provinceInfo.get(1));
            List<String> cityInfo = setEarthquakeMapService.queryCityByLonLat(longitude,latitude, provinceInfo.get(0));
            if (cityInfo.size() > 0) {
                item.setCity(cityInfo.get(1));
                List<String> countyInfo = setEarthquakeMapService.queryCountyByLonLat(longitude, latitude, cityInfo.get(0));
                if (countyInfo.size() > 0) {
                    item.setCounty(countyInfo.get(1));
                }
            }
//            String geom = "POINT("+longitude+" "+latitude+")";
//            item.setGeom(geom);
            item.setEventId(UUIDGenerator.getUUID().substring(0, 10));
            item.setCreateTime(new Date());
        }
        for (JcStrongCatalog item : list) {


        }

        return list;
    }


}
